﻿using static CyberU;
using static CyberU.UI;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Events;
using TMPro;
using UnityEngine.Rendering;

public class BaseRun : MonoBehaviour
{
    public TMP_FontAsset fallBackFont;
    [SerializeField]
    public Canvas canvasUICanvas;
    public void Awake()
    {
        defaultFont = fallBackFont;
        mainCamera = Camera.main;
        uiCanvas=GetOrAddComponent<UICanvas>(canvasUICanvas);
        canvasController=GetOrAddComponent<CanvasController>(this);
        // Delogc(canvasController);        
    }

    public void Start()
    {
        int antiAliasing = QualitySettings.antiAliasing;
        Debug.Log("当前抗锯齿 (Anti-Aliasing) 设置为: " + antiAliasing + "x");
        switch (antiAliasing)
        {
            case 0:
                Debug.Log("实际效果：无抗锯齿");
                break;
            case 1:
                Debug.Log("实际效果：2x 抗锯齿");
                break;
            case 2:
                Debug.Log("实际效果：4x 抗锯齿");
                break;
            case 4:
                Debug.Log("实际效果：8x 抗锯齿");
                break;
            default:
                Debug.Log("实际效果：未知抗锯齿级别");
                break;
        }
    }

    [RuntimeInitializeOnLoadMethod]
    static void OnRuntimeMethodLoad()
    {
        CheckRenderPipeline();
    }

    [ContextMenu("Check Render Pipeline")]
    public static void CheckRenderPipeline()
    {
        var pipelineAsset = GraphicsSettings.renderPipelineAsset;

        if (pipelineAsset == null)
        {
            Debug.Log("⚠️ 当前使用的是 Built-in Render Pipeline（内置渲染管线）");
            return;
        }

        string assetTypeName = pipelineAsset.GetType().Name;

        if (assetTypeName.Contains("UniversalRenderPipelineAsset"))
        {
            Debug.Log("✅ 当前使用的是 Universal Render Pipeline (URP)");
        }
        else if (assetTypeName.Contains("HDRenderPipelineAsset"))
        {
            Debug.Log("✅ 当前使用的是 High Definition Render Pipeline (HDRP)");
        }
        else
        {
            Debug.Log($"❓ 未知渲染管线: {assetTypeName}");
        }
    }
}